/******************************
* 引用前请确定使用的版本
* Powered By Leo
* 版本号: V2.5.110422
********************************/


<!--Ajax用户登录后默认事件-->
function logindone(){
	if($('login')) Element.hide('login');
	if($('loginStatus'))PG.loadTheContent('loginStatus','LoginStatus','&'+Math.random());
}


/*******************************上传功能专用**********************************/
function OnUploadCompleted(err,url,file,message){
	if(url==''){alert('请正确选择文件上传!\n'+message);return};
    if(err==0){
    	alert('上传成功('+url+')!!       ');
        PG.BrowserFile();
    }else{
    	alert('上传失败!!\n\n原因:'+message+'.      ');
	}
}
var PG = {
	IsAlert : true,/*是否显示提示信息*/
	MaxSelected :6,
	_FileDialog : null,
	_Path : '/',
	oFCKeditor : null,
	drawImageflag : false,
	mouseTimeout :[],
	fnPools : {fnLoad:[],fnResize:[]},
	selectObj : {text:null,value:null},
	addOnLoad : function(f){
		this.fnPools.fnLoad[this.fnPools.fnLoad.length] = f;
	},
	houseClick : function(id){
		new Ajax.Request('/houseClick.html',{query:'houseid='+id,method:'post'});
	},
	autoCompleter : function(id,upd,templatename,opts){
		opts = opts || {};
		opts.requestHeaders={HTTP_X_XMLHTTP_MODE:'true'};
		opts.parameters = 'f='+encodeURI(templatename)+'&timespan='+Math.random()
		opts.method = 'get';
		opts.frequency =0.1;
		url = location.pathname;
		var at = new Ajax.Autocompleter(id,upd, url, opts);
		Event.observe(id,'click',function(){this.activate();}.bind(at));
		return at;
	},
	drawImage : function(ImgD,iwidth,iheight){
		//参数(图片,允许的宽度,允许的高度)
		 var image=new Image();
		 image.src=ImgD.src;
		if(image.width>0 && image.height>0){
		 flag=true;
		if(image.width/image.height>= iwidth/iheight){
			if(image.width>iwidth){  
			 ImgD.width=iwidth;
			 ImgD.height=(image.height*iwidth)/image.width;
			 }else{
			 ImgD.width=image.width;  
			 ImgD.height=image.height;
			 }
			 ImgD.alt=image.width+"×"+image.height;
			 }
		else{
			if(image.height>iheight){  
			 ImgD.height=iheight;
			 ImgD.width=(image.width*iheight)/image.height;        
			 }else{
			 ImgD.width=image.width;  
			 ImgD.height=image.height;
			 }
			 ImgD.alt=image.width+"×"+image.height;
			 }
		 }
	} ,
	addOnResize : function(f){
		this.fnPools.fnResize[this.fnPools.fnResize.length] = f;
	},
	PageLoad : function(){
		for(var i=0;i<this.fnPools.fnLoad.length;i++){
			this.fnPools.fnLoad[i]();
		}
	},
	PageResize : function(){
		for(var i=0;i<this.fnPools.fnResize.length;i++){
			this.fnPools.fnResize[i]();
		}
	},
	ajaxLogin: function(){
		var w = new _window_({width:400,isModal:true,className:'ajaxlogin'});
		w.loadUrl('用户登录','/htmls/ajaxlogin.htm');
	},
	LogOut : function(toUrl){
			if(toUrl.substring(toUrl.length-1,1)=="/"){toUrl = toUrl.substring(0,toUrl.length-1)}
			dojo.xhrPost({url:"/logout.html",
					 sync : true,
					 load: function(){location.href=toUrl}
			})
			
	},
	chkLoginForm : function(sUser,sPassword){
		if($(sUser).value.length<3){
			alert('您的用户名还未填写!!');
			$(sUser).focus();
			return false;
		}
		if($(sPassword).value.length<3){
			alert('密码还未填写!!');
			$(sPassword).focus();
			return false;
		}
		return true;
	},
	temp : {},
	focus : function(el){
		if(el.value.indexOf('请输入')==0){
			this.temp[el.id] = el.value;
			el.value = '';
		}
	},
	blur : function(el){
		if(el.value.length==0)
			el.value = this.temp[el.id];
	},
	getDocumentHeight : function(){
/*		alert(document.body.scrollHeight);
		alert(document.documentElement.clientHeight);*/
		return document.documentElement.clientHeight;
		//return Math.max(document.documentElement.clientHeight,document.documentElement.scrollHeight);
	},
	getDocumentWidth : function(){
		return document.documentElement.clientWidth;
	},
	MakeTopAlign :function(el,parentEl){
		
		var top = Math.max(((Element.getHeight(parentEl)-Element.getHeight(el))/2),0)
		
		Element.setStyle(el,{top:top+'px'});
	},
	/*屏幕高度*/
	fillScreenHeight : function(){
		var arrayEl =[];
		for(var i=0;i<arguments.length;i++){
			if(arguments[i]&&$(arguments[i])){
				arrayEl[arrayEl.length] = $(arguments[i]);				
			}
		}
		this.fnPools.fnResize[this.fnPools.fnResize.length] = this.fillHeight.bind(PG,arrayEl);
		this.fillHeight(arrayEl);
	},
	fillHeight : function(a){
		var h=this.getDocumentHeight();
		if(Object.isString(a)){
			el = $(a);
			Element.setStyle(el,{height:(h-Element.cumulativeOffset(el).top)+'px'});
			return;
		}
		for(var i=0;i<a.length;i++){
			var el = a[i];
			var realHeight = Math.max(h-Element.cumulativeOffset(el).top,0)
			Element.setStyle(el,{height:realHeight+'px'});
		}
	},
	/*屏幕宽度*/
	fillScreenWidth : function(el,otherEl){
		this.fnPools.fnResize[this.fnPools.fnResize.length] = this.fillWidth.bind(PG,el,otherEl);
		this.fillWidth(el,otherEl);
	},
	fillWidth : function(el,otherEl){
		var w=this.getDocumentWidth();
		if(otherEl){
			for(var i=0;i<otherEl.length;i++){
				
				if(otherEl[i]&&$(otherEl[i])){

					w = w - Element.getWidth(otherEl[i]);			
				}
			}
		}
		Element.setStyle(el,{width:Math.max(w,0)+'px'});
	},
	/**********************************表单提交保存处理.b****************************************/
	saveContentCmd : function(tForm,opts){
		var rtnValue = false;
		try{
			opts = opts || {};
			if(opts.button&&$(opts.button)) $(opts.button).disabled=true;
			var d = Form.serialize(tForm);
			var myAjax = new Ajax.Request('/aspx/xmlhttppost.aspx',{
																		asynchronous:false, parameters: d ,method: 'post',
																		onComplete:function(bAlert,ajax){
																			rtnValue = this.returnSaveCmdResult(ajax,bAlert);
																			}.bind(this,opts.alert || false)
																		});		
		}catch(e){
			alert(e.message);
			rtnValue=false;
		}
		if(opts.button&&$(opts.button)) $(opts.button).disabled=false;
		return rtnValue;
	},
	/* 处理 提交数据后返回的代码和消息 */
	returnSaveCmdResult : function(ajax,bAlert){
		r = ajax.responseText;
		var arr = r.split(',');
		switch(arr[0])
		{
			case "1":
				if(bAlert) alert(arr[1],'提示');
				return true;
			case "2":
				if(bAlert) alert(arr[1],'提示');
				return true;
			default:
				alert(arr[1]);
				break;
		}
		return false;
	},
	/**********************************表单提交保存处理.e****************************************/
	openHtmlEditor : function(fnId,height){
		if(height==null) height = 320;
		this.oFCKeditor = new FCKeditor(fnId,"100%",height); 
		this.oFCKeditor.ReplaceTextarea();
		return;
	},
	GetContents : function(fnId){
		if(typeof(FCKeditorAPI)=='undefined'||FCKeditorAPI==null) return ;
		oEditor = FCKeditorAPI.GetInstance(fnId) ;
		if(oEditor)	$(fnId).value = oEditor.GetXHTML(true);
	},
	/* 加载内容divContent */
	loadContent : function(/*String*/fName,/*String*/opts){
		this.loadTheContent('divContent',fName,opts)
	},
	
	/* 加载内容 */
	loadTheContent : function(/*Object*/node,fName,opts){
		opts = opts || { };
		query = opts.query ||'';
		options = {
		  requestHeaders: {HTTP_X_XMLHTTP_MODE:'true'},
		  asynchronous:  true,
		  method: 'get',
		  parameters:   'f='+encodeURI(fName)+'&'+Math.random()+'&'+query,
		  evalJSON:     true,
		  evalJS:       true
		};
		Object.extend(options, opts);
		var url = location.pathname;
		return this.loadUrlContent(node,url,options)
	},
	loadUrlContent : function(/*Object*/node,/*String*/url,opts){
		opts = opts || { };
		query = opts.query ||'';
		options = {
			parameters:		query,
			evalJSON:     	true,
			method: 'get'
		};
		Object.extend(options, opts);
		return new Ajax.Updater(node,url,options);
	},
	Replace :function(content,value){
		alert(content.replace($key/ig,value));
		return content.replace('{0}',value);
	},
	/* 加载内容 */
	FileSelect : function(inputObj,ImgObj,title){
		if(document.readyState=='complete'){
			if(Object.isString(inputObj))inputObj = $(inputObj);
			if(Object.isString(ImgObj))ImgObj = $(ImgObj);
			var sFeatures = 'class=NOKIA,button=OK|CANCEL,width=480px,height=400px,resize=0,ismodal=1';
			var sTitle = '选择我的文件';
			var sQuery = 's=' + Math.random();
			new Ajax.Request('/my/MyFiles.html',{
				asynchronous:false,
				parameters: sQuery,
				method: 'get',
				evalJS: false,
				onSuccess: function(r) {
					PG._FileDialog=_window.Open(r.responseText,title, sFeatures);
					PG._FileDialog.OnOK= function(){
						var objValue = $('imgValue');
						if(objValue!=null){
							if(ImgObj!=null)ImgObj.src =objValue.value
							if(inputObj!=null)inputObj.value =objValue.value
							this.Hidden();
						}else{
							alert('对不起！！你还未选择文件！！\n请重新选择你上传的文件！！！');
						}
					}
				}
			});		
		}else{
			document.onreadystatechange=function(){
				PG.FileSelect(inputObj,ImgObj,title)
			}
		}
	},
	UploadFile :function (){
		Element.hide('browser');
		Element.removeClassName('tab-browser','current')
		Element.show('upload')
		Element.addClassName('tab-upload','current')
	},
	BrowserFile : function(sQuery){
		new Ajax.Request('/my/MyFiles.html',{
					asynchronous:false,
					parameters: 's='+Math.random()+'&'+sQuery,
					method: 'get',
					evalJS: false,
					onSuccess: function(r) {
						PG._FileDialog.SetContent(r.responseText)
					}
				});
		Element.hide('upload');
		Element.removeClassName('tab-upload','current')
		Element.show('browser')
		Element.addClassName('tab-browser','current')
	},
	loadOptions : function(/*Object|String*/node,/*string*/ fName,/*String*/query,/*boolean*/ fuseDefault){
		var obj = (Object.isString(node))? $(node):node;
		var q = 'f='+encodeURI(fName)+'&'+query;
		var tmp = obj.innerHTML;
		obj.disabled = true;
		Element.update(obj,'<option>加载数据中...<option>');
		try{
			new Ajax.Updater(obj,'/aspx/xmlhttp.aspx',{parameters: q ,method: 'get'});
		}catch(e){
			obj.update(tmp);
			alert(e.message);
		}
		obj.disabled = false;
	},
	loadCatalog : function(fnTargetObj,fnParentObj,fuseDefault){
		this.loadOptions((typeof(fnTargetObj)=='object')?fnTargetObj:$(fnTargetObj),(typeof(fnParentObj)=='object')?fnParentObj:$(fnParentObj),'分类目录选择',0||fuseDefault);
	},
	copy2clipboard : function(ss){
     window.clipboardData.setData("text",ss);
     alert("您已经复制了本页的链接，可以直接粘贴发给您的朋友。");
	},
	getOptionValues : function(objid,textobjid,valueobjid,flag){
		flag = (flag==null)?false:flag;
		var obj =  $(objid);
		if(obj==null){if(debug)alert("对不起,对象["+objid+"]未建立");return}
		var text='';
		var values='';
		for(var i=0;i<obj.options.length;i++){
			if(flag){
				text+=","+obj.options[i].text.replace(",","");
				values+=","+obj.options[i].value.replace(",","");
			}else if(obj.selectedIndex>-1){
				text=obj.options[i].text;
				values=obj.options[i].value;
				break;
			}
		}
		$(textobjid).value=text;
        $(valueobjid).value=values;
	},

	/* －－－－－－－－－－－－－－－　表单对象处理 Form.Element　－－－－－－－－－－－－－－－*/
	// 获得CheckBox元素的值 */
	getCheckBoxValue : function(fId){
		var str ="";
		var obj=document.getElementsByTagName("INPUT");
		for(var i=0;i<obj.length;i++)
			if(obj[i].type=="checkbox")
			{
				if(obj[i].id==fId||obj[i].name==fId)
				{
					if(obj[i].checked&&!obj[i].disabled)
					{
						str = str + "," + obj[i].value;
					}
				}
			}
		if(str.length>0) str = str.substring(1);
		return str;
	},
	// 获得RADIO元素的值 */
	getRadioValue : function(radio) {
		if (!radio.length && radio.type.toLowerCase() == 'radio'){
			return (radio.checked)?radio.value:'';
		}
		if (radio[0].tagName.toLowerCase() != 'input' ||radio[0].type.toLowerCase() != 'radio'){
			return '';
		}
		var len = radio.length; 
		for(i=0; i<len; i++){
			if (radio[i].checked){
				return radio[i].value;
				}
			}
		return '';
	},
	pop : function(node,me,f_){
		var obj = (Object.isString(node))? $(node):node;
		obj.style.display='block';
		obj.style.position='absolute';
		var _w = obj.clientWidth ; _h = obj.clientHeight;
		Position.clone(me,obj);
		obj.style.top = (obj.offsetTop + me.offsetHeight) + 'px';
		obj.style.width = _w;
		obj.style.height = _h;
		obj.onmouseout = function(){
			obj.style.display='none';
		}
		obj.onmouseover = function(){
			obj.style.display='block';
		}
	},
	doChecked : function(selectedNode,opts){
		opts = opts||{};
		classname = opts.className || 'check';
		selectedNode = $(selectedNode);
		var pNode = $(opts.parentNode || selectedNode.parentNode);
 		pNode.select(selectedNode.tagName).each(function(it){
			if(it==selectedNode){
				Element.addClassName(it,classname);
			}else{
				
				Element.removeClassName(it,classname);
			}
		});
/*		for(var i=0;i<pNode.childNodes.length;i++){
			if(pNode.childNodes[i]==selectedNode){
				alert(pNode.childNodes[i].innerHTML);
				Element.addClassName(pNode.childNodes[i],classname);
			}else{
				Element.removeClassName(pNode.childNodes[i],classname);
				
			}
		}*/
	},
	IsChecked : function(elName,imax){
		var obj	=document.getElementsByName(elName);
		var checked = false;
		imax = (imax==null)?obj.length:imax;
		var icount=0
		for(var i=0;i<obj.length;i++){
			if(obj[i].checked&&!obj[i].disabled){
				checked=true;
				icount++;
			}
			if(icount>imax){
				window.alert("您最多选择"+imax+"项.      ");
				return false;
			}
		}
		if(icount==0) window.alert("请至少选择一个");
		return checked;
	},
	/*第1参数为目录对象*/
	selectOptions : function(){
		if(arguments.length==0) return;
		var tObj = arguments[0];
		if(tObj.options.length>=this.MaxSelected){
			alert('对不起!!你只能选择'+this.MaxSelected+'项!!');
			return ;
		}
		var s = '',v = '';
		for(var i=1;i<arguments.length;i++)
		{
			if(arguments[i].selectedIndex > -1 ){
				s += arguments[i].options[arguments[i].selectedIndex].text + ' / ';
				v = arguments[i].options[arguments[i].selectedIndex].value;
			}
		}
		if(s.length>0){
			var oOption = new Option(s,v);
			tObj.options.add(oOption,-1);
		}
	},
	removeOptions : function(){
		for(var i=0;i<arguments.length;i++)
		{
			if(arguments[i].selectedIndex > -1){
				arguments[i].options[arguments[i].selectedIndex] ==null;
				arguments[i].removeChild(arguments[i].options[arguments[i].selectedIndex]);
			}
		}
	},
	// 获得Select元素的所有Options */
	getOptions : function(objid){
		var optionArray = $A($(objid));
		var text = [],value = [];
		optionArray.each(function(node){
				text.push(node.innerHTML);
				value.push(node.value);
		});
		return {text:text.join(','),value:value.join(',')};
	},
	loadVisited:function(key){
		var strCookie = this.getCookie('Visited_'+key);
		if(strCookie!=null&&$('visitedList')!=null){
			var myAjax = new Ajax.Updater('visitedList','/aspx/xmlhttp.aspx',{
																		parameters: 'f=visitedList&idlist='+strCookie+'&key='+key,
																		method: 'get',
																		evalJS: true
																		});
		}
	},
	addCart:function(key,val){
		var strCookie = this.getCookie('cart_'+key);
		if(strCookie!=null){
			var arrVisited = strCookie.split(',');
			//var pos = arrVisited.indexOf(val)
//			//if not Exists then Add
//			if(pos==-1){
//				if(arrVisited.length>=10) arrVisited.shift();
//				arrVisited.push(val);
//			}
			arrVisited.push(val);
			val=arrVisited.join(',');
		}
		this.setCookie('cart_'+key,val,1,this._Path);
	},
	getCart : function(key){
		return this.getCookie('cart_'+key);
	},
	clearCart : function(key){
		this.setCookie('cart_'+key,'',1,this._Path);
	},
	/* －－－－－－－－－－－－－－Cookie 设定　－－－－－－－－－－－－－－－*/
	setCookie : function(name, value, expires, path, domain, secure){
		var strCookie = name + "=" + value;
		
		if (expires){
			var dtmNow = new Date();
			dtmNow.setTime(dtmNow.getTime() + expires*24*60*60*1000);
			strCookie += "; expires=" + dtmNow.toGMTString();
		}
		strCookie +=  (path) ? "; path=" + path : "";
		strCookie +=  (domain) ? "; domain=" + domain : "";
		strCookie +=  (secure) ? "; secure" : "";
		document.cookie = strCookie;
	},
	getCookie : function(name){	
		var strCookies = document.cookie;
		var cookieName = name + "=";
		var intBegin, intEnd, strValue;
		intBegin = strCookies.indexOf(cookieName);
		if (intBegin == -1) return null;
		intEnd = strCookies.indexOf(";", intBegin);
		if (intEnd == -1) intEnd = strCookies.length;
		strValue = strCookies.substring(intBegin+cookieName.length,intEnd);
		return strValue;
	},
	Select : function(sName,txtId,valueId){
		if(document.readyState=='complete'){
		var tObj,vObj;
		tObj = Object.isString(txtId)?$(txtId):txtId;
		vObj = Object.isString(valueId)?$(valueId):valueId;
		
		if(tObj==null||vObj==null){
			alert('未定义的对象！！');
			return;			
		}
		if(tObj.tagName.toLowerCase()=='input'){
			sQuery = 'objText='+((vObj.value!='')?tObj.value:'')+'&objValue='+vObj.value;
		}else{
			sQuery = 'objText='+((vObj.value!='')?tObj.innerHTML:'')+'&objValue='+vObj.value;
		}
		var title = sName;
		new Ajax.Request('/aspx/xmlhttp.aspx',{parameters: 'f='+encodeURI(sName)+'&'+sQuery ,method: 'get',evalJS: true,onComplete: function(transport) {
			var dialogSelect = _window.Open(transport.responseText,title, 'ismodal=1,button=OK|CANCEL,width=420,height=200');
			dialogSelect.OnOK = function(){
				if(tObj.tagName.toLowerCase()=='input'){
					tObj.value = $('selectedText').innerHTML;
				}else{
					tObj.innerHTML=($('selectedText').innerHTML||'选择');
				}
				vObj.value=$('selectedValue').value;
				dialogSelect.Hidden();
			}
			}});
			}else{
				document.onreadystatechange=function(){
					PG.Select(sName,txtId,valueId)
				}
		}
	},
	/*运行ajax 窗口程序*/
	Open :	function (sName,sQuery,sTitle,sFeatures){
		var _w =null;
		if(document.readyState=='complete'){
			var title = (sTitle||sName);
			new Ajax.Request('/aspx/xmlhttp.aspx',{asynchronous:false,parameters: 'f='+encodeURI(sName)+'&'+sQuery ,method: 'get',evalJS: true,onSuccess: function(transport) {_w=_window.Open(transport.responseText,title, sFeatures);}});
		}else{
			document.onreadystatechange=function(){
				_w = PG.Open(sName,sQuery,sTitle,sFeatures);
			}
		}
		return _w;
	},
	Alert: function(sContent,sTitle,sFeatures){
		return _window.open(sContent,(sTitle||'提示'),sFeatures+',resize=no');
	},
	/*运行页面ajax指令*/
	doCmd : function(/*String*/fCmd,opts){
		opts = opts || {};
		isConfirm = opts.confirm || false;
		title = opts.title || fCmd;
		
		if(isConfirm){
			if(!window.confirm('您是否确定['+title+']？'))
			return false;
		}
	
		var sQuery = opts.query || '';
		
		var fIsAlert = opts.alert || false;
		
		var fMethod = opts.method || 'get';

		if(fMethod=='post'){
			var q = Math.random()+'&'+sQuery;
			var url = location.pathname + '?f='+encodeURI(fCmd);
		}else{
			var url = location.pathname;
			var q = 'f='+encodeURI(fCmd) + '&' + Math.random()+'&'+sQuery;
		}
		this.IsAlert = fIsAlert;
		var rtnValue = false;
		
		var myAjax = new Ajax.Request(url,{
											asynchronous:false,
											parameters: q ,method: fMethod,
											requestHeaders:{HTTP_X_XMLHTTP_MODE:'true'},
											onComplete:function(r){
												/*处理返回的数据*/
												rtnValue =  this.doResult(r.responseText);
											}.bind(this)});
		return rtnValue;
	},
	doCheckBoxOpen : function(fCb,url,imax,fArg){
		if(PG.IsChecked(fCb,imax)){
			window.open(url+'?'+fCb+'='+PG.getCheckBoxValue(fCb)+'&'+fArg);
		}
	},
	
	/*执行命令*/
	doCheckBoxCmd : function(fName,opts){
		opts = opts || {};
		fCb = opts.checkbox;
		if(PG.IsChecked(fCb)){
			opts.query += '&'+fCb+'='+PG.getCheckBoxValue(fCb)
			return PG.doCmd(fName,opts);
		}
	},
	doResult: function(fC){
		if(!fC){alert("提交服务器操作失败,请联系管理员!!! \nerr:"+fC);return false;}
		try{
			if(fC.split(",")[0].toString()=='1'){
				var message="操作成功!!!";
				if(fC.split(",").length>1)
					if(fC.split(",")[1].toString().length>0)
						var message=fC.split(",")[1].toString();
				/*是否回显提示*/
				if(this.IsAlert) alert(message);//_window.Alert(message, '提示');
				return true;
			}else if(fC.split(",")[0].toString()=='2'){
				/*是否回显提示*/
				if(this.IsAlert) alert('成功更新'+fC.split(",")[1]+'条记录!');//_window.Alert(message, '提示');
				return true;
			}else if(fC.split(",")[0].toString()=='102'){
				alert('找不到此更新的内容！！！('+fC.split(",")[0]+')');
				return false;
			}else if(fC.split(",")[0].toString()=='403'){
				this.doLogin();
				return false;
			}else if(fC.split(",")[0].toString()=='103'){
				if($('vCodeLine')) $('vCodeLine').style.display='';
				alert('验证码填写出错，请检查！！！('+fC.split(",")[0]+')');
				return false;
			}else{
				if(fC.split(",").length>1) var message = fC.split(",")[1].toString()
				//_window.Alert(message + "("+ fC.split(",")[0].toString() + ")", '提示','resize=no');
				alert(message + "("+ fC.split(",")[0].toString() + ")");
				return false;
			}
		}catch(e){alert(e.message);}
		return false;
	},
	doLogin : function(){
		alert('你还未登录系统,请登录后操作！！');
	},
	/* 复选框 全选 / 取消 /反选*/
	CheckBoxSelect : function(fId,flag){
		var obj=document.getElementsByTagName("INPUT");
		for(var i=0;i<obj.length;i++)
			if(obj[i].type=="checkbox"&&!obj[i].disabled)
			{
				if((!fId)||obj[i].id==fId||obj[i].name==fId){
					if(flag==2)
					{
						obj[i].checked=!obj[i].checked;
					}else{
						obj[i].checked=flag;
					}
				}
			}
	},
	doError : function(/*string*/text){
		alert(text)
	},
	mouseOut : function(id,opts){
		more = opts || {};
		this.mouseTimeout[id] = window.setTimeout(function(more){
			Element.hide(this);
			if(more.handle) Element.removeClassName(more.handle,'check');
			}.bind(id,more),more.timeout||300);
	},
	mouseOver : function(id,opts){
		more = opts || {};
		
		if(this.mouseTimeout){window.clearTimeout(this.mouseTimeout[id]);}
		if(more.handle) Element.addClassName(more.handle,'check');
		Element.show(id);
	}
	
}

Event.observe(window,'load',function(){this.PageLoad()}.bind(PG));
Event.observe(window,'resize',function(){this.PageResize()}.bind(PG));


PG.SWFPlayer = function(/*Object Id*/Obj,swf_width,swf_height){
	if(Object.isString(Obj)) Obj=$(Obj);
	if(Obj==null) return;
	Element.hide(Obj);
	var files='',links='',texts='';
	$$('#'+Obj.id+' ul li a').each(
		function(item){
			texts+=((texts=='')?'':'|')+item.title;
			links+=((links=='')?'':'|')+item.href;
		}
	)
	$$('#'+Obj.id+' ul li img').each(
		function(item){
			files+=((files=='')?'':'|')+item.src;
		}
	)
	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="'+ swf_width +'" height="'+ swf_height +'">');
	document.write('<param name="movie" value="/swf/bcastr3.swf"><param name="quality" value="high">');
	document.write('<param name="menu" value="false"><param name=wmode value="opaque">');
	document.write('<param name="FlashVars" value="bcastr_file='+files+'&bcastr_link='+links+'&bcastr_title='+texts+'">');
	document.write('<embed src="/swf/bcastr3.swf" wmode="opaque" FlashVars="bcastr_file='+files+'&bcastr_link='+links+'&bcastr_title='+texts+'& menu="false" quality="high" width="'+ swf_width +'" height="'+ swf_height +'" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />'); 
	document.write('</object>'); 
}
var Tween = {
	Quart: {
		easeOut: function(t,b,c,d){
			return -c * ((t=t/d-1)*t*t*t - 1) + b;
		}
	},
	Back: {
		easeOut: function(t,b,c,d,s){
			if (s == undefined) s = 1.70158;
			return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
		}
	},
	Bounce: {
		easeOut: function(t,b,c,d){
			if ((t/=d) < (1/2.75)) {
				return c*(7.5625*t*t) + b;
			} else if (t < (2/2.75)) {
				return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
			} else if (t < (2.5/2.75)) {
				return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
			} else {
				return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
			}
		}
	}
}
var SlideTrans = function(container, slider, count, options) {
    this._slider = $(slider);
    this._container = $(container);//容器对象
    this._timer = null;//定时器
    this._count = Math.abs(count);//切换数量
    this._target = 0;//目标值
    this._t = this._b = this._c = 0;//tween参数
    
    this.Index = 0;//当前索引
	this.timer = [];
    
    this.SetOptions(options);
    
    this.Auto = !!this.options.Auto;
    this.Duration = Math.abs(this.options.Duration);
    this.Time = Math.abs(this.options.Time);
    this.Pause = Math.abs(this.options.Pause);
    this.Tween = this.options.Tween;
    this.onStart = this.options.onStart;
    this.onFinish = this.options.onFinish;
    
    var bVertical = !!this.options.Vertical;
    this._css = bVertical ? "top" : "left";//方向
    
    //样式设置
    var p = Element.getStyle(this._container,'position');
    p == "relative" || p == "absolute" || (this._container.style.position = "relative");
    this._container.style.overflow = "hidden";
    this._slider.style.position = "absolute";
    this.initNum();
    this.Change = this.options.Change ? this.options.Change :
        this._slider[bVertical ? "offsetHeight" : "offsetWidth"] / this._count;
}
SlideTrans.prototype = {
  //设置默认属性
  SetOptions: function(options) {
    this.options = {//默认值
        Vertical:    true,//是否垂直方向（方向不能改）
        Auto:        true,//是否自动
        Change:        0,//改变量
        Duration:    50,//滑动持续时间
        Time:        0,//滑动延时
        Pause:        1000,//停顿时间(Auto为true时有效)
        onStart:    function(){},//开始转换时执行
        onFinish:    function(){},//完成转换时执行
        Tween:        Tween.Quart.easeOut//tween算子
    };
    Object.extend(this.options, options || {});
  },
  //开始切换
  Run: function(index) {
    //修正index
    index == undefined && (index = this.Index);
    index < 0 && (index = this._count - 1) || index >= this._count && (index = 0);
    //设置参数
    this._target = -Math.abs(this.Change) * (this.Index = index);
    this._t = 0;
    this._b = parseInt(this._slider.style[this.options.Vertical ? "top" : "left"]);
    this._c = this._target - this._b;
    this.onStart();
    this.Move();
  },
  initNum : function(){
	  var ul = document.createElement('div');
	  ul.className = 'num';
	  for(var i=1;i<=this._count;i++){
		  var li = document.createElement('a');
		  li.innerHTML = i;
		  li.onmouseover = function(li,i){
			  this._timer = setTimeout(function(li,i){  this.Auto = false; this.Run(i); }.bind(this,li,i), 100);
		  }.bind(this,li,i);
		  li.onmouseout = function(li,i){
			  clearTimeout(this._timer);  this.Auto = true; this.Run();
		  }.bind(this,li,i)
		  Insertion.Bottom(ul,li);
		  Element.setStyle(li,{	float: 'left',display:'block'});
	  }
	  Insertion.Bottom(this._container,ul);
	  Element.setStyle(ul,{position:'absolute', right:'5px', bottom:'5px', font:'12px/1.5 tahoma, arial', height:'18px'});
  },
  //移动
  Move: function() {
    clearTimeout(this._timer);
    //未到达目标继续移动否则进行下一次滑动
    if (this._c && this._t < this.Duration) {
        this.MoveTo(Math.round(this.Tween(this._t++, this._b, this._c, this.Duration)));
        this._timer = setTimeout(this.Move.bind(this), this.Time);
    }else{
        this.MoveTo(this._target);
        this.Auto && (this._timer = setTimeout( this.Next.bind(this), this.Pause));
    }
  },
  //移动到
  MoveTo: function(i) {
    this._slider.style[this._css] = i + "px";
  },
  //下一个
  Next: function() {
    this.Run(++this.Index);
  },
  //上一个
  Previous: function() {
    this.Run(--this.Index);
  },
  //停止
  Stop: function() {
    clearTimeout(this._timer); this.MoveTo(this._target);
  }
}
/*******************************************************************/
function Slider(container, frequency, direction) {
  if (typeof(container) == 'string') {
    container = $(container);
  }
  this.container = container;
  this.frequency = frequency;
  this.direction = direction;
  this.films = [];
  this._playTimeoutId = null;
  this._slideTimeoutId = null;
  this._slidable = true;
	this._current = 0;

  var divs = this.container.getElementsByTagName('dl');
  for (var i = 0; i < divs.length; i++) {
      divs[i].onmouseover = function(self){return function(){self._mouseover()};}(this);
      divs[i].onmouseout = function(self){return function(){self._mouseout()};}(this);
  }
  this._loop();
}

Slider.prototype = {
  _loop : function() {
    var sb = this;
    this._playTimeoutId = setTimeout(function(){sb._slide()}, this.frequency);
  },

  _slide : function() {
    var sb = this;
		//$('test').innerHTML+=sb.container.id+'='+sb._slidable+'<br/>';
		if(sb._slidable){
			var c = sb.container;
			Effect.Fade(c.getElementsByTagName('dl')[this._current],{duration:1,from:0.8,to:0});
			this._current++;
			if(this._current>=c.getElementsByTagName('dl').length){
					this._current=0
			}
			Effect.Appear(c.getElementsByTagName('dl')[this._current]);
		}
    this._playTimeoutId = setTimeout(function(){sb._slide()}, this.frequency);
  },

  _mouseover : function() {
    this._slidable = false;
  },

  _mouseout : function() {
    this._slidable = true;
  }
}
/********* 星级评分 V1.0 Powered By Leo 2010/10/28**************/
_star_ = Class.create();
_star_.prototype.initialize = function(opts){
	opts = opts || {};
	this.input = opts.input ;
	this.className = opts.className || 'star_';
	this.value = opts.value || 0;	//返回值
	this.maxValue = opts.maxValue || 5;
	this.minValue = opts.minValue || 0;
	this.htmlControl = opts.html ;
	this.inputControl = opts.input ;
	this.stepValue = opts.stepValue || 1;
	this.readonly = opts.readonly || false;
	this.star = opts.star || '/images/common/star_rating2.gif';
	this.selected = false;
	this.initStar($(opts.container),$(opts.slider));
}
_star_.prototype.initStar = function(container,slider){
	this.container = container || document.createElement('div')
	this.slider = slider || document.createElement('span');
	Insertion.Top(this.container,this.slider)
	this.setSelectedValue(this.value);
	
	var percent = (this.selectedValue/this.maxValue*100);
	
	Element.setStyle(this.slider,{
		display:'block'
		,width:percent+'%'
		,height:Element.getHeight(this.container) +'px'
		,textIndent:'-10000px'
		});
	if(!this.readonly){
		Element.setStyle(this.slider,{cursor:'pointer'});
		Event.observe(this.container,'click',function(e){
			/*if(this.selected){*/
				this.onSliderChange(e);
				this.value = this.selectedValue;
				this.onClick(this.value);
		/*	}*/
			}.bind(this));
		
		Event.observe(this.container,'mousemove',function(e){
			/*if(this.selected){*/
				this.onSliderChange(e);
		/*	}*/
			}.bind(this));
		Event.observe(this.container,'mouseout',function(e){
			tmp = (this.value/this.maxValue)*100;;
			Element.setStyle(this.slider,{
				width:tmp+'%'
				});
			this.setSelectedValue(this.value);
		}.bind(this));
	}
}
_star_.prototype.onSliderChange = function(e){
	step = (this.stepValue/this.maxValue)*100;
	tmp = Math.ceil((Event.pointerX(e)-Element.cumulativeOffset(this.container).left)/this.container.offsetWidth*100/step)*step;
	value = tmp/100 * this.maxValue;
	Element.setStyle(this.slider,{
		width:tmp+'%'
		});
	this.setSelectedValue(value);
}


_star_.prototype.setSelectedValue = function(value){
	this.selectedValue = value;	//待选值
	this.container.title=value;
	Element.update(this.slider,value);
	this.onChange();
}
_star_.prototype.setValue = function(){
	this.value = this.selectedValue;
}
//待选值修改事件
_star_.prototype.onChange = function(){
	if(this.htmlControl&&$(this.htmlControl))	Element.update(this.htmlControl,this.selectedValue);
	if(this.inputControl&&$(this.inputControl)) {$(this.inputControl).value = this.selectedValue;}
}
//点击事件
_star_.prototype.onClick = function(value){
	this.setValue(value);
	
}
_star_.prototype.getValue = function(){
	return this.value;
}

/********* 弹出层 V0.8 Powered By Leo 2010/06/11**************/
_window_zIndex_ = 10000;
_window_ = Class.create();
_window_.prototype.initialize = function(ops_Features){
	ops_Features = (ops_Features==null)?{}:ops_Features;
	this.className = ops_Features.className || 'dooll';
	this.width = ops_Features.width || 300;
	this.isModal = ops_Features.isModal || false;
	this.resize = ops_Features.resize || false;
	this.draggable = ops_Features.draggable || false;
	this.buttons = ops_Features.buttons || {enabled:false};
	this.zIndex = 100;
}
_window_.prototype.setOptions = function(options){
	
}
_window_.open=function(content,title,features)
{
	var obj=new _window_(features);
	obj.create(content,title);
	return obj;
}

_window_.alert=function(content,title,features)
{
	features = features || {};
	features.isModal = true;
	features.buttons = {enabled:true,OK:true};

	var obj= new _window_(features);
	obj.create(content,title||"Alert");
	return obj;
}

_window_.confirm=function(content,title,features)
{
	features = features || {};
	features.isModal = true;
	features.buttons = {enabled:true,OK:true,Cancel:true};
	
	var obj=new _window_(features);
	obj.create(content,title||"Confirm");
/*	obj.buttons["CANCEL"].focus();*/
	return obj;
}

_window_.prototype.create=function(content,title)
{


	/*对象创建*/
	this.divContainer=document.createElement("div");
	this.divTitle=document.createElement("div");
	this.divContent=document.createElement("div");
	this.divTitleContent=document.createElement("div");
	this.spanClose=document.createElement("span");

	Insertion.Bottom(this.divTitle,this.spanClose);
	Insertion.Bottom(this.divTitle,this.divTitleContent);
	
	Insertion.Bottom(this.divContainer,this.divTitle);
	Insertion.Bottom(this.divContainer,this.divContent);
	
	Insertion.Bottom(document.body,this.divContainer);
	
	/*内容容器*/
	
	Element.addClassName(this.divContainer,'window_');
	Element.addClassName(this.divContainer,this.className);
	Element.setStyle(this.divContainer,{
					 width:  this.width + 'px',
					 //height: this.height + 'px',
					 position : 'absolute',
					 zIndex : _window_zIndex_++,
					 backgroundColor:'#999'
					 });

	//标题栏

	this.divTitle.className='title_';
	

	this.divTitleContent.className='titleContent_';
	this.divTitleContent.innerHTML = title || 'title';


	this.spanClose.className='close_';
	this.spanClose.innerHTML='&nbsp;';
	Event.observe(this.spanClose,'click',this.close.bind(this));
	Event.observe(this.spanClose,'mouseover',function(){Element.addClassName(this,'hover')});
	Event.observe(this.spanClose,'mouseout',function(){Element.removeClassName(this,'hover')});

	
	this.divTitle.onselectstart = function(){return false;}
	
	//内容
	
	this.divContent.className='content_';
	Element.update(this.divContent,content);

	//样式
	Element.setStyle(this.spanClose,{
					 float: 'right'
					 ,display : 'block'
					 ,cursor: 'default'
					 ,width:'26px'
					 });
	Element.setStyle(this.divTitleContent,{
					 float: 'left'
					 ,cursor: 'default'
					 ,overflow: 'hidden'
					 ,whiteSpace: 'nowrap'
					 ,width: (Element.getWidth(this.divTitle)-70) +'px'
					 });
	

	Event.observe(window,'scroll',this.onScroll.bind(this));
	Event.observe(window,'resize',this.onResize.bind(this));

	if(this.isModal){
		/* Modal 层*/
		this.modal=document.createElement("div");
		this.modal.className="Modal_";
		Element.update(this.modal,'<iframe></iframe>');
		Insertion.Bottom(document.body,this.modal);
		Element.setStyle(this.modal,{
					 zIndex : 9999,
					 left : 0,
					 top : 0,
					 position : "absolute",
					 overflow: 'hidden'
					 });
	}
	//new Effect.Opacity(this.divContainer,{from:0.0,to:1.0}); 
	this.onResize();
	this.onScroll();
	//this.setDraggable(this.draggable);

	if(this.buttons.enabled) this.enabledButtons();
}
_window_.prototype.enabledButtons = function(){
	this.divButtons=document.createElement("div");
	this.divButtons.className ='buttons_';
	if(this.buttons.OK){
		this.buttonOK = document.createElement("div");
		this.buttonOK.innerHTML="&nbsp;";
		this.buttonOK.className = 'OK_';
		Insertion.Bottom(this.divButtons,this.buttonOK);
		Event.observe(this.buttonOK,'click',function(){
													this.OnOK()
													}.bind(this)
													);
		Element.setStyle(this.buttonOK,{
						 float:'right'
						 });
		Insertion.Bottom(this.divButtons,this.buttonOK);
	}
	Insertion.Bottom(this.divContainer,this.divButtons);
}
_window_.prototype.OnOK = function(){
	this.close();
}
_window_.prototype.setContent=function(content){
	if(this.divContent)
		Element.update(this.divContent,content);
	else
		this.create(content);
}
_window_.prototype.setResponseContent=function(title,r){
	this.setContent(r.responseText);
	this.setTitle(title);
}
_window_.prototype.loadContent=function(title,fName,query,bAsyn){
	PG.loadFuncContent(this.setResponseContent.bind(this,title),fName,query,bAsyn);
}
_window_.prototype.loadObject=function(title,obj,isCopy){
	var obj = Object.isString(obj)?$(obj):obj;
	if(!isCopy) {Element.hide(obj);Element.remove(obj)}
	this.setContent(obj.innerHTML)
	this.setTitle(title);
}
/*加载远程*/
_window_.prototype.loadUrl=function(title,url,query,bAsyn){
	new Ajax.Request(url,{
		asynchronous:bAsyn&&true,
		evalScripts:true,
		parameters: query +'?'+Math.random(),
		method: 'get',
		onSuccess: this.setResponseContent.bind(this,title)
		});
}
_window_.prototype.setTitle = function(title){
	if(this.divTitleContent){
		Element.update(this.divTitleContent,title);
	}
}
_window_.prototype.setDraggable = function(status){
	if(status)
		this.dragContainer = new Draggable(this.divContainer,{handle:'title_'});
	else if(this.dragContainer){
		this.dragContainer.destroy();
	}
}
_window_.prototype.onScroll=function(){
	var scrollvalue = Position.realOffset(document.documentElement);
	Element.setStyle(this.divContainer,{
					 left:  (this.left+scrollvalue.left) + 'px',
					 top: (this.top+scrollvalue.top) + 'px'
					 });
}

_window_.prototype.close = function(){
	this.OnClose();
	if(this.isModal) Element.hide(this.modal)
	Element.hide(this.divContainer)
	this.remove();
}
_window_.prototype.OnClose=function(){
}
_window_.prototype.remove = function(){
	if(this.isModal){Element.remove(this.modal);this.modal=null}
	Element.remove(this.divContainer)
}
_window_.prototype.onResize = function(){
	var w = document.documentElement.clientWidth //Element.getWidth(document.documentElement);
	var h = document.documentElement.clientHeight//Element.getHeight(document.documentElement);
	if(this.isModal){
		Element.setStyle(this.modal,{
					 width : w +'px',
					 height : Math.max(h,document.documentElement.scrollHeight)  +'px'
					 });
	}
	this.left = (w - Element.getWidth(this.divContainer)) /2 
	this.top = Math.max(0,(h - Element.getHeight(this.divContainer)-50) /2)
	Element.setStyle(this.divContainer,{
					 left:  this.left + 'px',
					 top: this.top + 'px'
					 });
	
}

/********* 颜色选择器 V1.0 Powered By Leo 2009/03/11**************/
function ColorTable(instance){
	this.Instance = new String(instance);
	this.Color = "#000000";
	this.Callback = null;
	var flag = -1;
	var PreviewCellID = Global.GetUniqueID();
	var RGBID = Global.GetUniqueID();
	var LayerID = Global.GetUniqueID();
	var Colors = "#000000,#000000,#000000,#000000,#003300,#006600,#009900,#00cc00,#00ff00,#330000,#333300,#336600,#339900,#33cc00,#33ff00,#660000,#663300,#666600,#669900,#66cc00,#66ff00,#000000,#333333,#000000,#000033,#003333,#006633,#009933,#00cc33,#00ff33,#330033,#333333,#336633,#339933,#33cc33,#33ff33,#660033,#663333,#666633,#669933,#66cc33,#66ff33,#000000,#666666,#000000,#000066,#003366,#006666,#009966,#00cc66,#00ff66,#330066,#333366,#336666,#339966,#33cc66,#33ff66,#660066,#663366,#666666,#669966,#66cc66,#66ff66,#000000,#999999,#000000,#000099,#003399,#006699,#009999,#00cc99,#00ff99,#330099,#333399,#336699,#339999,#33cc99,#33ff99,#660099,#663399,#666699,#669999,#66cc99,#66ff99,#000000,#cccccc,#000000,#0000cc,#0033cc,#0066cc,#0099cc,#00cccc,#00ffcc,#3300cc,#3333cc,#3366cc,#3399cc,#33cccc,#33ffcc,#6600cc,#6633cc,#6666cc,#6699cc,#66cccc,#66ffcc,#000000,#ffffff,#000000,#0000ff,#0033ff,#0066ff,#0099ff,#00ccff,#00ffff,#3300ff,#3333ff,#3366ff,#3399ff,#33ccff,#33ffff,#6600ff,#6633ff,#6666ff,#6699ff,#66ccff,#66ffff,#000000,#ff0000,#000000,#990000,#993300,#996600,#999900,#99cc00,#99ff00,#cc0000,#cc3300,#cc6600,#cc9900,#cccc00,#ccff00,#ff0000,#ff3300,#ff6600,#ff9900,#ffcc00,#ffff00,#000000,#00ff00,#000000,#990033,#993333,#996633,#999933,#99cc33,#99ff33,#cc0033,#cc3333,#cc6633,#cc9933,#cccc33,#ccff33,#ff0033,#ff3333,#ff6633,#ff9933,#ffcc33,#ffff33,#000000,#0000ff,#000000,#990066,#993366,#996666,#999966,#99cc66,#99ff66,#cc0066,#cc3366,#cc6666,#cc9966,#cccc66,#ccff66,#ff0066,#ff3366,#ff6666,#ff9966,#ffcc66,#ffff66,#000000,#ffff00,#000000,#990099,#993399,#996699,#999999,#99cc99,#99ff99,#cc0099,#cc3399,#cc6699,#cc9999,#cccc99,#ccff99,#ff0099,#ff3399,#ff6699,#ff9999,#ffcc99,#ffff99,#000000,#00ffff,#000000,#9900cc,#9933cc,#9966cc,#9999cc,#99cccc,#99ffcc,#cc00cc,#cc33cc,#cc66cc,#cc99cc,#cccccc,#ccffcc,#ff00cc,#ff33cc,#ff66cc,#ff99cc,#ffcccc,#ffffcc,#000000,#ff00ff,#000000,#9900ff,#9933ff,#9966ff,#9999ff,#99ccff,#99ffff,#cc00ff,#cc33ff,#cc66ff,#cc99ff,#ccccff,#ccffff,#ff00ff,#ff33ff,#ff66ff,#ff99ff,#ffccff,#ffffff".split(",");
	this.ShowTable = function(callBack,x,y){
		if(flag != 1){
			return;
		}
		if("function" != typeof(callBack)) return;
		this.Callback = callBack;
		document.getElementById(LayerID).style.display = "";
		document.getElementById(LayerID).style.top = parseInt(y,10);
		document.getElementById(LayerID).style.left = parseInt(x,10);
	}
	
	this.Init = function(){
		if(flag != (-1)){
			return;
		}
		if(window[this.Instance] != this){
			throw new Error(-1,"");
		}
		flag = 0;
	}
	this.SetColor = function(color){
		if(flag != 1){
			return;
		}
		this.Color = new String(color).toUpperCase();
		document.getElementById(PreviewCellID).style.backgroundColor = this.Color;
		document.getElementById(RGBID).innerHTML = this.Color;
	}
	
	this.Select =  function(color){
		if(flag != 1){
			return;
		}
		this.Color = new String(color).toUpperCase();
		if("function" == typeof(this.Callback))
			this.Callback(this.Color);
		this.Hide();
	}
	this.Draw = function(){
		if(flag == (-1)){
			this.Init();
		}
		if(flag != 0){
			return ;
		}
		var shtml = "";
		shtml += '<div id="' + LayerID + '" style="position:absolute;display:none;top:0px;left:0px;width:214px;height:145px;overflow:visible;border:0px;z-index:999999;">';
		shtml += this.GetTable();
		shtml += '</div>';
		
		document.write(shtml);
		flag = 1;
	}
	
	this.Hide = function(){
		if(flag != 1){
			return;
		}
		document.getElementById(LayerID).style.display = "none";
	}
	this.GetTable = function(){
		var shtml = '\
			<table width="214" onmousedown="event.cancelBubble=true;" height="145" border="0" cellpadding="0" cellspacing="0" style="border:solid 1px #000000">\n\
			<tr>\n\
				<td height="20" bgcolor="#D4D0C8" scope="col"><table width="100%" style="margin:2px;" border="0" cellspacing="0" cellpadding="0">\n\
				<tr>\n\
					<td width="24%" height="20" style="background-color:#ffffff;border:solid 1px #000000" scope="col" id="' + PreviewCellID + '">&nbsp;</td>\n\
					<td width="43%" height="20" scope="col"><div align="center" style="font-family:宋体;font-size:9pt;" id="' + RGBID + '"></div></td>\n\
					<td width="33%" height="20" scope="col"><div align="center"></div></td>\n\
				</tr>\n\
				</table></td>\n\
			</tr>\n\
			<tr>\n\
				<td>';
		shtml += '<table border="0" cellspacing="1" bgcolor="#000000">';
		shtml += '<tr height="10">';
		for(var i=0,l=Colors.length;i<l;i++){
			if(i%21 == 0){
				shtml += "</tr><tr>";
			}
			shtml += '<td height="10" width="10" bgcolor="' + Colors[i] + '" style="cursor:hand;" onmouseover="' + this.Instance + '.SetColor(bgColor)" onmousedown="' + this.Instance + '.Select(bgColor)"></td>';
		}
		shtml += '</table>';
		shtml += '	</td>\n\
					</tr>\n\
				</table>';
		return shtml;
	}
}

/**	Div 选择器 V1.0
	2010-06-11 Powerby Leo */
divSelect = Class.create();
divSelect.prototype.initialize = function(obj,opts){
	opts = opts || {};
	this.container = $(obj);
	this.textCss = opts.textCss || '.text';
	this.optionCss = opts.optionCss || '.options';
	this.timeout = opts.timeout || 300;
	this.selectedIndex = opts.selectedIndex || 0;
	this.mode = opts.mode || 1 ; // 1 为点击模式, 2 移动模式
	this.width = opts.width;
	this.init();
	this.initEvent();
}
divSelect.prototype.init = function(){

	if(this.container!=null){
		this.oSelectText = this.container.select(this.textCss)[0];
		this.oOption = this.container.select(this.optionCss)[0];
		this.selectedText = this.oSelectText.innerHTML;
		var w = (this.width)?this.width:(Element.getWidth(this.container)-2);
		Element.setStyle(this.oOption,{width:Math.max(w,0)+'px'});
		this.select();
	}
}
divSelect.prototype.initEvent=function(){
	
	Event.observe(this.oSelectText,'click',this.showOption.bind(this));

	Event.observe(this.oSelectText,'mouseover',this.mouseOver.bind(this));
	Event.observe(this.oSelectText,'mouseout',this.mouseOut.bind(this));

	Event.observe(this.oOption,'mouseover',this.mouseOver.bind(this));
	Event.observe(this.oOption,'mouseout',this.mouseOut.bind(this));
	this.oOption.select('a').each(this.initItemEvent.bind(this));
}

divSelect.prototype.initItemEvent=function(it){
	Event.observe(it,'click',this.onClick.bind(this,it));
}

divSelect.prototype.onClick = function(it){
	Element.update(this.oSelectText,it.innerHTML);
	this.selectedText = it.innerHTML;
	this.onChange(it);
	this.hideOption();
}
divSelect.prototype.onChange = function(){}

divSelect.prototype.select = function(){
	if(this.selectedIndex!=0)
		Element.update(this.oSelectText,this.oOption.childNodes[this.selectedIndex].innerHTML);
}
divSelect.prototype.mouseOut = function(e){
	this.timeid = window.setTimeout(this.hideOption.bind(this),this.timeout);
}
divSelect.prototype.mouseOver = function(e){
	window.clearTimeout(this.timeid);
	this.showOption(e);
}
divSelect.prototype.showOption = function(e){
	window.clearTimeout(this.timeid);
	Element.show(this.oOption);
	if(Element.visible(this.oOption)){Element.addClassName(this.oSelectText,'check');}else{Element.removeClassName(this.oSelectText,'check')}
}
divSelect.prototype.hideOption = function(){
	Element.hide(this.oOption);
	
	Element.removeClassName(this.oSelectText,'check');
}
divSelect.prototype.importSelect = function(objSelect){
}



/**************Tips******************/
_Tip_= Class.create();
_Tip_.prototype.initialize=function(item,foritem){
	Event.observe(foritem,'mouseover',this.show.bind(item));
	Event.observe(foritem,'mouseout',this.hide.bind(item));
}
_Tip_.prototype.show=function(evt){
	//alert(Event.pointerX(evt));
	Element.setStyle(this,{
					 position: 'absolute',
					 left:Event.pointerX(evt),
					 top: Event.pointerY(evt)
					 });
	Element.show(this);
}

_Tip_.prototype.hide=function(item){
	Element.hide(this);
}

/**	选项卡 V0.4
	2010-06-11 Powerby Leo */

tabManage = Class.create();
tabManage.prototype.initialize=function(item,opts){
	opts = opts || {};
	this.Object = $(item);
	this.inited = [];
	this.action = opts.action || 'mouseover';
	this.title = this.Object.select(opts.titleCss || '.title li');
	this.contents = this.Object.select(opts.contentCss || '.content');
	this.selectedIndex = opts.selectedIndex || 0;
	this.onChange = opts.onChange || {};
	this.autoSecond = opts.autoSecond || 0; //自动切换秒数,0不自动切换
	if(this.title.length==0||this.contents==null) return;
	this.init();
	this.bindEvent();
}
tabManage.prototype.init= function(){
	//清理非法的
	this.title.each(function(item){
		if(Element.hasClassName(item,'more')||Element.hasClassName(item,'none')){
			this.title = this.title.without(item);
		}
	}.bind(this))
	this.contents.each(function(item){
		if(Element.hasClassName(item,'none')){
			this.contents = this.contents.without(item);
		}
	}.bind(this))
	
	this.selectIndex(this.getIndex());
	if(this.autoSecond>0) this.doPlay();
}
tabManage.prototype.getIndex = function(){
	for(var i=0;i<this.title.length;i++){
		if(Element.hasClassName(this.title[i],'check')){
			return i;
		}
	}
	return this.selectedIndex;
}
tabManage.prototype.createContent=function(){
	
}
tabManage.prototype.selectIndex= function(j){
	for(var i=0;i<this.title.length;i++){
		if(i==j){
			Element.addClassName(this.title[i],'check');
			if(i<this.contents.length){
				Element.show(this.contents[i]);
			}else{
				
			}
		}else{
			Element.removeClassName(this.title[i],'check');
			if(i<this.contents.length){
				Element.hide(this.contents[i]);
			}else{
				
			}
		}
	}
	if(typeof this.onChange =='function') this.onChange(j);
}

tabManage.prototype.bindEvent=function(){
	for(var i=0;i<this.title.length;i++){
		Event.observe(this.title[i], this.action, this.onClick.bind(this,i));
	}
}
tabManage.prototype.onClick = function(j,e){
	this.selectIndex(j);
	
	Event.stop(e);
}
tabManage.prototype.doPlay = function(){
	window.clearInterval(this.timer);
	this.timer = window.setInterval(this.autoPlay.bind(this),this.autoSecond*1000);
}
tabManage.prototype.autoPlay = function(){
	var cIndex = this.getIndex()+1;
	if(cIndex>=this.title.length) cIndex = 0;
	this.selectIndex(cIndex)
}


